Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/release distribution exchange examples #210

Merged
merged 10 commits into from
Mar 8, 2024

Conversation

aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Mar 8, 2024

  • Release latest changes in dev branch related to the distribution and chain exchange modules into master

Summary by CodeRabbit

  • New Features

    • Introduced automated reviews and chat replies configuration through .coderabbit.yaml.
    • Added voting functionality on blockchain proposals using InjectiveLabs and Cosmos SDK.
    • Enhanced blockchain network functionalities with distribution and chain exchange modules, including handling rewards, commissions, and market operations.
    • Updated trading pair configurations across devnet, mainnet, and testnet environments, including new tokens and adjustments to tick sizes and quantities.
    • Expanded suite of functionalities for distribution and exchange modules, including market launches, reward queries, and detailed exchange information.
  • Enhancements

    • Improved handling of account addresses and initialization of distribution query clients in blockchain client.
    • Refined trading environment settings for better precision and usability in trading operations.
  • Documentation

    • Added extensive examples for distribution and exchange module operations, offering detailed guidance on new functionalities.

Copy link

coderabbitai bot commented Mar 8, 2024

Walkthrough

The update introduces a comprehensive suite of functionalities for automated chat interactions and blockchain-based voting and trading operations. It enhances the system's ability to handle distribution and exchange modules within a blockchain network, specifically targeting the InjectiveLabs and Cosmos SDK frameworks. Additionally, it adjusts trading parameters across different network environments and expands the system's querying capabilities for various blockchain-related information.

Changes

Files Change Summary
.coderabbit.yaml Introduced automated reviews and replies in chat.
auth_vote/authz_vote.go Added voting functionality for blockchain proposals using InjectiveLabs and Cosmos SDK.
client/chain/chain.go, client/chain/chain_test_support.go Enhanced with distribution and exchange module functionalities, including new methods and significant updates to existing ones. Adjusted imports and data types.
client/metadata/assets/devnet.ini, client/metadata/assets/mainnet.ini, client/metadata/assets/testnet.ini Adjusted trading parameters and added configurations for new tokens and trading pairs across different network environments.
examples/chain/distribution/* & examples/chain/exchange/* Introduced comprehensive functionalities and queries for distribution and exchange modules, including market operations and querying capabilities.

"In the realm of code, where logic does play,
A rabbit hopped in, bringing updates today.
Votes cast in blockchains, trades swiftly made,
With automated chats, no delay in aid.
🌟 From devnet to main, in tests we trust,
A leap towards the future, in CodeRabbit we must."
🐰✨


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 0.63291% with 471 lines in your changes are missing coverage. Please review.

Project coverage is 25.01%. Comparing base (bbd39ef) to head (2ccf24b).

Files Patch % Lines
client/chain/chain.go 0.86% 343 Missing ⚠️
client/chain/chain_test_support.go 0.00% 128 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
- Coverage   29.71%   25.01%   -4.71%     
==========================================
  Files          17       17              
  Lines        2564     3022     +458     
==========================================
- Hits          762      756       -6     
- Misses       1766     2234     +468     
+ Partials       36       32       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aarmoa aarmoa merged commit 8a251c5 into master Mar 8, 2024
2 of 4 checks passed
@aarmoa aarmoa deleted the release/release_distribution_exchange_examples branch March 8, 2024 13:42
Comment on lines +61 to +67
res, err := chainClient.FetchChainPositions(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error from chainClient.FetchChainPositions(ctx) is only printed, lacking comprehensive error handling. Enhance error management by considering program exit or retry mechanisms.

Comment on lines +22 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded values in the Cosmos keyring initialization present a security issue. Leverage environment variables or configuration files for handling sensitive data.

Comment on lines +60 to +66
res, err := chainClient.FetchTradeRewardCampaign(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimal error handling for chainClient.FetchTradeRewardCampaign(ctx) is observed, with only error printing. Consider implementing more robust error handling strategies.

Comment on lines +22 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of hardcoded values for Cosmos keyring initialization is a security concern. Employ environment variables or configuration files to securely manage sensitive information.

Comment on lines +60 to +66
res, err := chainClient.FetchFeeDiscountSchedule(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for chainClient.FetchFeeDiscountSchedule(ctx) is limited to printing the error. Enhance error management with more comprehensive strategies.

Comment on lines +22 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded values in Cosmos keyring initialization pose a security risk. Use environment variables or configuration files for secure management of sensitive data.

Comment on lines +60 to +66
res, err := chainClient.FetchBalanceMismatches(ctx, 1)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling for chainClient.FetchBalanceMismatches(ctx, 1) is minimal, with only error printing. Consider more robust error handling approaches.

Comment on lines +23 to +31
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using hardcoded values for Cosmos keyring initialization is a security issue. Consider environment variables or configuration files for secure handling of sensitive information.

Comment on lines +61 to +67
res, err := chainClient.FetchExchangeBalances(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for chainClient.FetchExchangeBalances(ctx) is limited to printing the error. Implement more comprehensive error handling strategies for better robustness.

Comment on lines +22 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded values in the initialization of the Cosmos keyring are a security concern. Opt for environment variables or configuration files to securely manage sensitive data.

Comment on lines +60 to +66
res, err := chainClient.FetchBalanceWithBalanceHolds(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling for chainClient.FetchBalanceWithBalanceHolds(ctx) is minimal, only involving error printing. Consider adopting more robust error handling techniques.

Comment on lines +22 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The practice of using hardcoded values for Cosmos keyring initialization is a security risk. Employ environment variables or configuration files for the secure handling of sensitive information.

Comment on lines +60 to +66
res, err := chainClient.FetchFeeDiscountTierStatistics(ctx)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for chainClient.FetchFeeDiscountTierStatistics(ctx) is limited to printing the error. More comprehensive error handling strategies should be considered.

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private key is hardcoded in the source code, which poses a significant security risk. Hardcoding sensitive information like private keys can lead to accidental exposure and misuse. It's recommended to use environment variables or secure vaults for managing sensitive data.

Comment on lines +63 to +66
res, err := chainClient.FetchChainExpiryFuturesMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling for the chainClient.FetchChainExpiryFuturesMarketInfo function call. Currently, if an error occurs, it's printed to the console, but the program will continue to execute and attempt to marshal a potentially nil res variable, which could lead to a runtime panic. Consider adding a return statement after printing the error to prevent further execution in case of an error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchChainExpiryFuturesMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchChainExpiryFuturesMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the previous file, the private key is hardcoded, which is a critical security issue. Always avoid hardcoding sensitive information in the source code. Use environment variables or secure vaults to manage such data securely.

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of a hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) in the source code raises a significant security concern. Hardcoding sensitive information like private keys can lead to security vulnerabilities and should be avoided. Consider using environment variables or secure vaults to manage sensitive data.

Comment on lines +62 to +65
res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling for the chainClient.FetchValidatorDistributionInfo call. Currently, if an error occurs, it is printed, but the program will continue to execute and attempt to marshal a potentially nil res. This could lead to a runtime panic. Consider adding a return statement after printing the error to prevent further execution in case of an error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the previous file, the hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) presents a security risk. Avoid hardcoding sensitive information in the source code. Use environment variables or secure vaults for managing sensitive data.

Comment on lines +62 to +65
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper error handling is missing for the chainClient.FetchDerivativeMidPriceAndTOB call. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil and lead to a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security issue. Hardcoding sensitive information like private keys in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.

Comment on lines +62 to +65
res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchValidatorOutstandingRewards call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. It's advisable to halt execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.

Comment on lines +63 to +66
res, err := chainClient.FetchChainDerivativeMarket(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchChainDerivativeMarket call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchChainDerivativeMarket(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchChainDerivativeMarket(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security concern. Avoid hardcoding sensitive information like private keys in the source code. Use environment variables or secure vaults for managing sensitive data.

Comment on lines +63 to +66
res, err := chainClient.FetchAggregateMarketVolume(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchAggregateMarketVolume call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. It's advisable to halt execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchAggregateMarketVolume(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchAggregateMarketVolume(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security issue. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.

Comment on lines +63 to +66
res, err := chainClient.FetchHistoricalTradeRecords(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchHistoricalTradeRecords call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchHistoricalTradeRecords(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchHistoricalTradeRecords(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.

Comment on lines +63 to +66
res, err := chainClient.FetchDerivativeMarketAddress(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchDerivativeMarketAddress call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchDerivativeMarketAddress(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchDerivativeMarketAddress(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security concern. Avoid hardcoding sensitive information like private keys in the source code. Use environment variables or secure vaults for managing sensitive data.

Comment on lines +63 to +66
res, err := chainClient.FetchChainPerpetualMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchChainPerpetualMarketInfo call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchChainPerpetualMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchChainPerpetualMarketInfo(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +18 to +74
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
limit := uint64(2)
limitCumulativeNotional := cosmostypes.Dec{}

res, err := chainClient.FetchChainDerivativeOrderbook(ctx, marketId, limit, limitCumulativeNotional)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/22_DerivativeOrderbook/example.go file, the error handling after the JSON marshalling operation (line 72) is missing. It's a good practice to always check for errors after operations that can fail, such as JSON marshalling, to ensure the robustness of the code.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
limit := uint64(2)
limitCumulativeNotional := cosmostypes.Dec{}
res, err := chainClient.FetchChainDerivativeOrderbook(ctx, marketId, limit, limitCumulativeNotional)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security issue. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Consider using environment variables or secure vaults for managing sensitive data.

Comment on lines +63 to +66
res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchSubaccountDeposit call is insufficient. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +16 to +74
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

withdrawAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"

msg := &types.MsgSetWithdrawAddress{
DelegatorAddress: senderAddress.String(),
WithdrawAddress: withdrawAddress,
}

//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msg)

if err != nil {
panic(err)
}

str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/distribution/1_SetWithdrawAddress/example.go file, the error handling after the JSON marshalling operation (line 73) is missing. It's important to handle errors returned by the json.MarshalIndent function to catch any potential issues during the marshalling process.

- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
withdrawAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
msg := &types.MsgSetWithdrawAddress{
DelegatorAddress: senderAddress.String(),
WithdrawAddress: withdrawAddress,
}
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msg)
if err != nil {
panic(err)
}
str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(response, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Comment on lines +23 to +30
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded private key (5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e) is a security risk. Hardcoding sensitive information in the source code can lead to security vulnerabilities. Use environment variables or secure vaults for managing sensitive data instead.

Comment on lines +63 to +66
res, err := chainClient.FetchChainPerpetualMarketFunding(ctx, marketId)
if err != nil {
fmt.Println(err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for the chainClient.FetchChainPerpetualMarketFunding call is inadequate. If an error occurs, it's printed, but the program will still attempt to marshal and print res, which could be nil, potentially causing a runtime panic. Consider halting execution with a return statement after printing the error.

if err != nil {
	fmt.Println(err)
+	return
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
res, err := chainClient.FetchChainPerpetualMarketFunding(ctx, marketId)
if err != nil {
fmt.Println(err)
}
res, err := chainClient.FetchChainPerpetualMarketFunding(ctx, marketId)
if err != nil {
fmt.Println(err)
return
}

Comment on lines +15 to +70
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
subaccountId := chainClient.Subaccount(senderAddress, 0)
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"}

res, err := chainClient.FetchChainSpotOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/17_SpotOrdersByHashes/example.go file, the error handling after the JSON marshalling operation (line 69) is missing. Proper error handling is crucial for identifying issues during the marshalling process and ensuring the program's reliability.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
subaccountId := chainClient.Subaccount(senderAddress, 0)
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"}
res, err := chainClient.FetchChainSpotOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}

Comment on lines +17 to +72
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z"
startingHeight := uint64(0)
endingHeight := uint64(0)
pagination := query.PageRequest{Limit: 10}
ctx := context.Background()

res, err := chainClient.FetchValidatorSlashes(ctx, validatorAddress, startingHeight, endingHeight, &pagination)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/distribution/query/4_ValidatorSlashes/example.go file, the error handling after the JSON marshalling operation (line 71) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z"
startingHeight := uint64(0)
endingHeight := uint64(0)
pagination := query.PageRequest{Limit: 10}
ctx := context.Background()
res, err := chainClient.FetchValidatorSlashes(ctx, validatorAddress, startingHeight, endingHeight, &pagination)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Comment on lines +16 to +77
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

subaccountId := chainClient.Subaccount(senderAddress, 0)

res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String())
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))

res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex())
if err != nil {
fmt.Println(err)
}

str, _ = json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/4_AggregateVolume/example.go file, the error handling after both JSON marshalling operations (lines 68 and 76) is missing. It's crucial to handle errors returned by the json.MarshalIndent function to catch any potential issues during the marshalling process and ensure the program's reliability.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

This change should be applied after both marshalling operations in the file.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
subaccountId := chainClient.Subaccount(senderAddress, 0)
res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String())
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex())
if err != nil {
fmt.Println(err)
}
str, _ = json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
subaccountId := chainClient.Subaccount(senderAddress, 0)
res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String())
if err != nil {
fmt.Println(err)
}
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))
res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex())
if err != nil {
fmt.Println(err)
}
str, err = json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))
}

Comment on lines +15 to +70
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
subaccountId := chainClient.Subaccount(senderAddress, 0)
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"}

res, err := chainClient.FetchChainDerivativeOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/25_DerivativeOrdersByHashes/example.go file, the error handling after the JSON marshalling operation (line 69) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"
subaccountId := chainClient.Subaccount(senderAddress, 0)
orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"}
res, err := chainClient.FetchChainDerivativeOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Comment on lines +17 to +75
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

amount := types.NewCoin("inj", types.NewInt(1))

msg := &distriutiontypes.MsgFundCommunityPool{
Amount: []types.Coin{amount},
Depositor: senderAddress.String(),
}

//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msg)

if err != nil {
panic(err)
}

str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/distribution/4_FundCommunityPool/example.go file, the error handling after the JSON marshalling operation (line 74) is missing. It's important to handle errors returned by the json.MarshalIndent function to catch any potential issues during the marshalling process and ensure the program's reliability.

- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
amount := types.NewCoin("inj", types.NewInt(1))
msg := &distriutiontypes.MsgFundCommunityPool{
Amount: []types.Coin{amount},
Depositor: senderAddress.String(),
}
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msg)
if err != nil {
panic(err)
}
str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(response, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Comment on lines +18 to +77
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
tradeHistoryOptions := types.TradeHistoryOptions{
TradeGroupingSec: 10,
MaxAge: 0,
IncludeRawHistory: true,
IncludeMetadata: true,
}

res, err := chainClient.FetchMarketVolatility(ctx, marketId, &tradeHistoryOptions)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/52_MarketVolatility/example.go file, the error handling after the JSON marshalling operation (line 76) is missing. Proper error handling is crucial for identifying issues during the marshalling process and ensuring the program's reliability.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
tradeHistoryOptions := types.TradeHistoryOptions{
TradeGroupingSec: 10,
MaxAge: 0,
IncludeRawHistory: true,
IncludeMetadata: true,
}
res, err := chainClient.FetchMarketVolatility(ctx, marketId, &tradeHistoryOptions)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}

Comment on lines +19 to +76
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)

if err != nil {
panic(err)
}

ctx := context.Background()

marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
limit := uint64(2)
orderSide := types.OrderSide_Buy
limitCumulativeNotional := cosmostypes.Dec{}
limitCumulativeQuantity := cosmostypes.Dec{}

res, err := chainClient.FetchChainSpotOrderbook(ctx, marketId, limit, orderSide, limitCumulativeNotional, limitCumulativeQuantity)
if err != nil {
fmt.Println(err)
}

str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the examples/chain/exchange/query/14_SpotOrderbook/example.go file, the error handling after the JSON marshalling operation (line 75) is missing. It's a good practice to always check for errors after operations that can fail, such as JSON marshalling, to ensure the robustness of the code.

- str, _ := json.MarshalIndent(res, "", " ")
+ str, err := json.MarshalIndent(res, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"inj-user",
"12345678",
"5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionGasPrices(client.DefaultGasPriceWithDenom),
)
if err != nil {
panic(err)
}
ctx := context.Background()
marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
limit := uint64(2)
orderSide := types.OrderSide_Buy
limitCumulativeNotional := cosmostypes.Dec{}
limitCumulativeQuantity := cosmostypes.Dec{}
res, err := chainClient.FetchChainSpotOrderbook(ctx, marketId, limit, orderSide, limitCumulativeNotional, limitCumulativeQuantity)
if err != nil {
fmt.Println(err)
}
str, _ := json.MarshalIndent(res, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Comment on lines +18 to +103
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}

if err != nil {
panic(err)
}

senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"gov_account",
"",
"", // keyring will be used if pk not provided
false,
)

if err != nil {
panic(err)
}

clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)

if err != nil {
panic(err)
}

clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)

txFactory := chainclient.NewTxFactory(clientCtx)
txFactory = txFactory.WithGasPrices(client.DefaultGasPriceWithDenom)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionTxFactory(&txFactory),
)

if err != nil {
panic(err)
}

// note that we use grantee keyring to send the msg on behalf of granter here
// sender, subaccount are from granter
validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"}
grantee := senderAddress.String()
proposalId := uint64(375)
var msgs []sdk.Msg

for _, validator := range validators {
msgVote := v1beta1.MsgVote{
ProposalId: proposalId,
Voter: validator,
Option: v1beta1.OptionYes,
}

msg0Bytes, _ := msgVote.Marshal()
msg0Any := &codectypes.Any{}
msg0Any.TypeUrl = sdk.MsgTypeURL(&msgVote)
msg0Any.Value = msg0Bytes

msg := &authztypes.MsgExec{
Grantee: grantee,
Msgs: []*codectypes.Any{msg0Any},
}

sdkMsg := sdk.Msg(msg)
msgs = append(msgs, sdkMsg)
}

//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msgs...)

if err != nil {
panic(err)
}

str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the auth_vote/authz_vote.go file, the error handling after the JSON marshalling operation (line 102) is missing. Proper error handling is essential for catching any issues that may occur during the marshalling process, which can help in debugging and ensuring the program's robustness.

- str, _ := json.MarshalIndent(response, "", " ")
+ str, err := json.MarshalIndent(response, "", " ")
+ if err != nil {
+     fmt.Println("Error marshalling JSON:", err)
+     return
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func main() {
network := common.LoadNetwork("testnet", "lb")
tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket")
if err != nil {
panic(err)
}
if err != nil {
panic(err)
}
senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring(
os.Getenv("HOME")+"/.injectived",
"injectived",
"file",
"gov_account",
"",
"", // keyring will be used if pk not provided
false,
)
if err != nil {
panic(err)
}
clientCtx, err := chainclient.NewClientContext(
network.ChainId,
senderAddress.String(),
cosmosKeyring,
)
if err != nil {
panic(err)
}
clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient)
txFactory := chainclient.NewTxFactory(clientCtx)
txFactory = txFactory.WithGasPrices(client.DefaultGasPriceWithDenom)
chainClient, err := chainclient.NewChainClient(
clientCtx,
network,
common.OptionTxFactory(&txFactory),
)
if err != nil {
panic(err)
}
// note that we use grantee keyring to send the msg on behalf of granter here
// sender, subaccount are from granter
validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"}
grantee := senderAddress.String()
proposalId := uint64(375)
var msgs []sdk.Msg
for _, validator := range validators {
msgVote := v1beta1.MsgVote{
ProposalId: proposalId,
Voter: validator,
Option: v1beta1.OptionYes,
}
msg0Bytes, _ := msgVote.Marshal()
msg0Any := &codectypes.Any{}
msg0Any.TypeUrl = sdk.MsgTypeURL(&msgVote)
msg0Any.Value = msg0Bytes
msg := &authztypes.MsgExec{
Grantee: grantee,
Msgs: []*codectypes.Any{msg0Any},
}
sdkMsg := sdk.Msg(msg)
msgs = append(msgs, sdkMsg)
}
//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msgs...)
if err != nil {
panic(err)
}
str, _ := json.MarshalIndent(response, "", " ")
fmt.Print(string(str))
str, err := json.MarshalIndent(response, "", " ")
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
fmt.Print(string(str))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant